package chenji.gunapi.events;

import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

public class MouseClickEvent extends Event implements Cancellable {
	private Player p;
	private int typeid;
	private boolean state;
	private MouseButtonType type;
	private boolean canceled = false;
	private static final HandlerList handlers = new HandlerList();

	public enum MouseButtonType {
		LEFT, RIGHT, MIDDLE;
	}

	public MouseClickEvent(Player p, int button, boolean state) {
		this.p = p;
		this.typeid = button;
		this.state = state;
		if (this.typeid == 0) {
			this.type = MouseButtonType.LEFT;
		}
		if (this.typeid == 1) {
			this.type = MouseButtonType.RIGHT;
		}
		if (this.typeid == 2) {
			this.type = MouseButtonType.MIDDLE;
		}
	}

	public Player getPlayer() {
		return this.p;
	}

	@Deprecated
	public int getTypeId() {
		return this.typeid;
	}

	public boolean getState() {
		return this.state;
	}

	public MouseButtonType getType() {
		return this.type;
	}

	@Override
	public boolean isCancelled() {
		return canceled;
	}

	@Override
	public void setCancelled(boolean arg0) {
		this.canceled = arg0;
	}

	@Override
	public HandlerList getHandlers() {
		return handlers;
	}	

	public static HandlerList getHandlerList() {
		return handlers;
	}

}
